$("#formToAddRo").submit(function (e) {

    var num = $("#cycle").val();


    $.ajax({
        type: "post",//方法类型
        dataType: "json",//预期服务器返回的数据类型
        // url: "/loginLog/login?loginname="+loginname+"&password="+password,
        // data:JSON.stringify($("#login-form")),
        url: "/rotationArea/addRo",
        data: {cycle: num},
        success: function (result) {
            if (result.code == 200) {
                ShowMsg(result.msg);
            } else if (result.code == -1) {
                ShowMsg(result.msg);
            }
            return true;
        },
        error: function () {

            ShowMsg("请重试！");
            return false
        }
    });


})


function addRA(id) {
    $("#roID").val(id);
    $("#addCardialog").css("display", "block");

}

function updateRA(id) {
    $("#cycleid").val(id);
    $("#delallpartdialog").css("display", "block");

}

function deleteRA(id){


    var file = new FormData();
    file.append("objectid", id);

    $.ajax({
        url: "/rotationArea/deleteCarouselContent",
        type: "post",
        data: file,
        cache: false,
        contentType: false,
        processData: false,
        success: function (data) {
            ShowMsg(data.msg);
            return false;
        }
    });

}

$("#updateCycle").on("click", function () {
    var file = new FormData();
    file.append("objectid", $("#cycleid").val());
    file.append("cycle", $("#cycleUp").val());
    $.ajax({
        url: "/rotationArea/updateRotationArea",
        type: "post",
        data: file,
        cache: false,
        contentType: false,
        processData: false,
        success: function (data) {
            ShowMsg(data.msg);
            return false;
        }
    });
    return false;
});
$("#subAddcarousel_content").on("click", function () {
    // alert("tij")
    var pic = $('#img')[0].files[0];
    var file = new FormData();
    file.append("img", pic);
    file.append("ywobjectid", $("#ywID").val());
    file.append("rotationid", $("#roID").val());
    $.ajax({
        url: "/rotationArea/uploadImgAndAddYw",
        type: "post",
        data: file,
        cache: false,
        contentType: false,
        processData: false,
        success: function (data) {


            ShowMsg(data.msg);
            return false;
        }
    });

    return false;
})


//左选择
$('#ywID').focus(function () {
    $(".showUlleft").slideDown('fast').show();
});
$("#ywID").bind("input propertychange", function (event) {
    var inputval = $('#ywID').val().toLowerCase();
    $(".showUlleft>li").each(function () {
        var self = $(this);
        if (self.text().toLowerCase().startsWith(inputval)) {
            self.css("display", "block")
        } else {
            self.css("display", "none")
        }
    });
});

$(".showUlleft").on("click", "a", function (event) {
    var target = $(event.target);
    $('#ywID').val($(this).text());//给input赋值
    $(".showUlleft>li>a").each(function () {
        var self = $(this);
        if (self.css("background-color") == "rgb(66, 185, 131)") {
            self.css("background-color", "#ffffff")
        }
    });
    target.css("background-color", "#42B983");
});
$('#ywID').blur(function () {
    $(".showUlleft").slideUp('500').show();
});